<?php
include_once ("dblib.php");

/**
 * This class is used to handle all the queries to the database
 */
class queryHandler {

    /**
     *Each query has three elements, a variable, an operator an a value to assign
     */
    private $var;
    private $operator;
    private $value;

    /**
     *The constructor creates a query with all the necessary elements.
     * @param <string> $var var to be assigned
     * @param <string> $operator operator in the relation
     * @param <string> $value value to assign
     */
    function __construct($var, $operator, $value) {

        $this->var = $var;
        $this->operator = $operator;
        $this->value = "'".$value."'";
    }

    /**
     *It returns the value of the var element.
     * @return <string> var of the query
     */
    function getVar() {
        return $this->var;
    }

    /**
     *This function updates the id of an element
     * @param <type> $structHandler
     * @param <type> $parametros
     */
    function updateIdVar($structHandler,$parametros){
        $this->var = $structHandler->getId($parametros['root_name'].$this->var);
    }

    /**
     *It returns the value of the operator element.
     * @return <string> operator of the query
     */
    function getOperator() {
        return $this->operator;
    }

    /**
     *It returns the value of the value element.
     * @return <string> value of the query
     */
    function getValue() {
        return $this->value;
    }
/**
 *It returns a modificated string with the correct structure to be
 * @param <type> $numTabla
 * @return <type>
 */
    function getString($numTabla) {
        return " t".$numTabla.".id_structure=".$this->var." AND t$numTabla.value=$this->value ";
    }
}

?>